import { DataSourceType, DataSourceStatus } from "@/constants/dataSource";

export enum DataSourceType {
  MySQL = "mysql",
  PostgreSQL = "postgresql",
  SQLServer = "sqlserver",
  Oracle = "oracle",
  MongoDB = "mongodb",
  Redis = "redis",
  Elasticsearch = "elasticsearch",
}

export enum DataSourceStatus {
  Connected = "connected",
  Disconnected = "disconnected",
  Error = "error",
}

export interface DataSource {
  id: number;
  name: string;
  type: DataSourceType;
  host: string;
  port: number;
  database: string;
  username: string;
  password: string;
  status: DataSourceStatus;
  testing?: boolean;
  createdAt?: string;
  updatedAt?: string;
}

export interface DataSourceQuery {
  keyword?: string;
  page: number;
  pageSize: number;
}

export interface DataSourceResponse {
  list: DataSource[];
  total: number;
}

export interface TableInfo {
  name: string;
  comment?: string;
  type: string;
}

export interface TableListResponse {
  tables: TableInfo[];
  views: TableInfo[];
}

export interface ColumnInfo {
  name: string;
  type: string;
  nullable: boolean;
  key?: string;
  default?: string;
  comment?: string;
}

export interface TableDataQuery {
  page: number;
  pageSize: number;
  condition?: string;
}

export interface TableDataResponse {
  list: any[];
  total: number;
}

export interface DbStructure {
  id: string;
  label: string;
  type: "folder" | "table" | "view";
  children?: DbStructure[];
}

export interface SqlPreviewResult {
  columns: string[];
  data: any[];
}
